Mac5120 (#283)
authortsteven4 <tsteven4@users.noreply.github.com>
Sat, 2 Feb 2019 22:41:52 +0000 (15:41 -0700)
committerGitHub <noreply@github.com>
Sat, 2 Feb 2019 22:41:52 +0000 (15:41 -0700)
* add generic qt installer for osx.

add travis builds with osx and qt 5.9.7, 5.12.0
update qtci extract-qt-installer from upstream.
add some error detection and debug to travis_install_osx, travis_intall_linux_local.

* catch qtci/install-qt up with upstream.

* try harder with early extract-qt-installer bugs on osx.

* don't source travis qt install scripts.

* fix caching for travis.

* qt installer improvements

validate installs
add debug for failed installs

* update travis osx qt 5.12 build to 5.12.1.

.travis.yml
tools/qtci/extract-qt-installer
tools/qtci/install-qt
tools/qtci/qt-5.9.5-osx [deleted file]
tools/travis_install_linux_coverage
tools/travis_install_linux_local
tools/travis_install_osx
tools/travis_script_linux_coverage

index d12d13d21e9453a29bb8d30362cc65a56ff886e3..bfc21bc973346c06f7b5c8f2362f13d6b16ebfd0 100644 (file)
@@ -22,6 +22,7 @@ matrix:
       compiler: gcc
       env:
         - BUILD_TYPE="local"
+        - QT_VERSION="5.9.7"
       addons:
         apt:
           packages:
@@ -36,13 +37,21 @@ matrix:
             - libgl1-mesa-dev
       cache:
         directories:
-          - $HOME/Qt
+          - $HOME/Cache
         timeout: 600
     - os: osx
       compiler: clang
+      env: QT_VERSION="5.9.7"
       cache:
         directories:
-          - $HOME/Qt
+          - $HOME/Cache
+        timeout: 600
+    - os: osx
+      compiler: clang
+      env: QT_VERSION="5.12.1"
+      cache:
+        directories:
+          - $HOME/Cache
         timeout: 600
     - os: linux
       dist: xenial
@@ -50,6 +59,7 @@ matrix:
       compiler: gcc
       env:
         - BUILD_TYPE="coverage"
+        - QT_VERSION="5.7.1"
       addons:
         apt:
           packages:
@@ -58,12 +68,12 @@ matrix:
             - lcov
       cache:
         directories:
-          - $HOME/Qt
+          - $HOME/Cache
 
 install:
-  - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "coverage" ]; then ./tools/travis_install_linux_coverage; fi
-  - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "local" ]; then source ./tools/travis_install_linux_local; fi
-  - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then source ./tools/travis_install_osx; fi
+  - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "coverage" ]; then ./tools/travis_install_linux_coverage ${QT_VERSION} && source ${HOME}/Cache/qt-${QT_VERSION}.env; fi
+  - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "local" ]; then ./tools/travis_install_linux_local ${QT_VERSION} && source ${HOME}/Cache/qt-${QT_VERSION}.env; fi
+  - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./tools/travis_install_osx ${QT_VERSION} && source ${HOME}/Cache/qt-${QT_VERSION}.env; fi
 
 script:
   - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TYPE}" = "coverage" ]; then ./tools/travis_script_linux_coverage; fi
@@ -74,7 +84,7 @@ script:
 after_success:
   - cd ${TRAVIS_BUILD_DIR}
   # only deploy pushes to master or prs that target master.  the prs will go to transfr.sh, the pushes go to github.
-  - if [ "${TRAVIS_OS_NAME}" = "osx" ] && [ "$TRAVIS_BRANCH" = "master" ]; then bash ./tools/uploadtool/upload.sh  gui/objects/GPSBabel-*.dmg; fi
+  - if [ "${TRAVIS_OS_NAME}" = "osx" ] &&  [ "${QT_VERSION}" = "5.9.7" ] && [ "$TRAVIS_BRANCH" = "master" ]; then bash ./tools/uploadtool/upload.sh  gui/objects/GPSBabel-*.dmg; fi
 
 branches:
   except:
index 545fdcf5cab7846f579998a2e3609d651f0900a5..8a49925d74c194ab1c4833d8241ae5a6020c5299 100755 (executable)
@@ -3,14 +3,48 @@
 # License: Apache-2.0
 # https://github.com/benlau/qtci
 
+function usage() {
+    echo "Usage:"
+    echo "extract-qt-installer qt-installer output_path"
+    echo "extract-qt-installer --list-packages qt-installer"
+    exit -1
+}
+
+unset DISPLAY
+echo $DISPLAY
+
+LIST_PACKAGES=0
+
+getopt --test > /dev/null 2>&1
+GETOPT_RET_CODE=$?
+
 set -e #quit on error
 
-if [ $# -lt 2 ];
+if [ "$GETOPT_RET_CODE" != "4" ]
 then
-    echo extract-qt-installer qt-installer output_path
-    exit -1
+    echo "Warning: gnu-getopt is not installed. Long parameter like '--list-package' will not be working. Please install gnu-getopt by 'brew install gnu-getopt'"   
+else
+
+       OPTS=`getopt -o l --long list-packages --long disable-progress-report -n "extract-qt-installer" -- "$@"`
+
+    eval set -- "$OPTS"
+
+    while true
+    do
+      case "$1" in
+        --list-packages)
+          LIST_PACKAGES=1
+          shift;;
+           --disable-progress-report)
+             DISABLE_PROGRESS_REPORT=1
+             shift;;
+        --) shift;break;;
+        *) shift;;
+      esac
+    done
 fi
 
+
 export PATH=$PATH:$PWD
 export WORKDIR=$PWD
 INSTALLER=$1
@@ -18,10 +52,29 @@ OUTPUT=$2
 SCRIPT="$(mktemp /tmp/tmp.XXXXXXXXX)"
 PACKAGES=$QT_CI_PACKAGES
 
-if [[ ! "${OUTPUT:0:1}" = "/" ]] 
+if [ $LIST_PACKAGES -gt 0 ]
 then 
-    echo output path must be an absolute path
-    exit -1
+
+       if [ $# -lt 1 ]
+       then
+               usage
+       fi
+       
+       OUTPUT="/tmp/Qt"
+
+else
+
+       if [ $# -lt 2 ]
+       then
+               usage
+       fi
+
+       if [[ ! "${OUTPUT:0:1}" = "/" ]] 
+       then 
+               echo output path must be an absolute path
+               exit -1
+       fi
+    
 fi
 
 cat <<EOF > $SCRIPT
@@ -56,30 +109,95 @@ function log() {
     console.log(msg.join(" "));
 }
 
+function printObject(object) {
+       var lines = [];
+       for (var i in object) {
+               lines.push([i, object[i]].join(" "));
+       }
+       log(lines.join(","));
+}
+
+var status = {
+       widget: null,
+       finishedPageVisible: false,
+       installationFinished: false
+}
+
+function tryFinish() {
+       if (status.finishedPageVisible && status.installationFinished) {
+        if (status.widget.LaunchQtCreatorCheckBoxForm) {
+            // Disable this checkbox for minimal platform
+            status.widget.LaunchQtCreatorCheckBoxForm.launchQtCreatorCheckBox.setChecked(false);
+        }
+        if (status.widget.RunItCheckBox) {
+            // LaunchQtCreatorCheckBoxForm may not work for newer versions.
+            status.widget.RunItCheckBox.setChecked(false);
+        }
+        log("Press Finish Button");
+           gui.clickButton(buttons.FinishButton);
+       }
+}
+
 function Controller() {
     installer.installationFinished.connect(function() {
+               status.installationFinished = true;
         gui.clickButton(buttons.NextButton);
+        tryFinish();
     });
     installer.setMessageBoxAutomaticAnswer("OverwriteTargetDirectory", QMessageBox.Yes);
     installer.setMessageBoxAutomaticAnswer("installationErrorWithRetry", QMessageBox.Ignore);
+    
+    // Allow to cancel installation for arguments --list-packages
+    installer.setMessageBoxAutomaticAnswer("cancelInstallation", QMessageBox.Yes);
 }
 
 Controller.prototype.WelcomePageCallback = function() {
     log("Welcome Page");
-    gui.clickButton(buttons.NextButton, 3000);
+    gui.clickButton(buttons.NextButton);
+
+    var widget = gui.currentPageWidget();
+
+    widget.completeChanged.connect(function() {
+        gui.clickButton(buttons.NextButton);
+    });
 }
 
 Controller.prototype.CredentialsPageCallback = function() {
+       
+       var login = installer.environmentVariable("QT_CI_LOGIN");
+       var password = installer.environmentVariable("QT_CI_PASSWORD");
+
+       if (login === "" || password === "") {
+               gui.clickButton(buttons.CommitButton);
+       }
+       
+    var widget = gui.currentPageWidget();
+
+       widget.loginWidget.EmailLineEdit.setText(login);
+
+       widget.loginWidget.PasswordLineEdit.setText(password);
+
     gui.clickButton(buttons.CommitButton);
 }
 
 Controller.prototype.ComponentSelectionPageCallback = function() {
+    log("ComponentSelectionPageCallback");
 
-    var components = installer.components();
-    log("Available components: " + components.length);
+    function list_packages() {
+      var components = installer.components();
+      log("Available components: " + components.length);
+      var packages = ["Packages: "];
 
-    for (var i = 0 ; i < components.length ;i++) {
-        log(components[i].name);
+      for (var i = 0 ; i < components.length ;i++) {
+          packages.push(components[i].name);
+      }
+      log(packages.join(" "));
+    }
+      
+    if ($LIST_PACKAGES) {
+        list_packages();
+        gui.clickButton(buttons.CancelButton);
+        return;
     }
 
     log("Select components");
@@ -93,10 +211,30 @@ Controller.prototype.ComponentSelectionPageCallback = function() {
     var packages = trim("$PACKAGES").split(",");
     if (packages.length > 0 && packages[0] !== "") {
         widget.deselectAll();
+        var components = installer.components();
+        var allfound = true;
         for (var i in packages) {
             var pkg = trim(packages[i]);
-               log("Select " + pkg);
-               widget.selectComponent(pkg);
+            var found = false;
+            for (var j in components) {
+                if (components[j].name === pkg) {
+                    found = true;
+                    break;
+                }
+            }
+            if (!found) {
+                allfound = false;
+                log("ERROR: Package " + pkg + " not found.");
+            } else {
+                log("Select " + pkg);
+                widget.selectComponent(pkg);
+            }
+        }
+        if (!allfound) {
+            list_packages();
+            // TODO: figure out how to set non-zero exit status.
+            gui.clickButton(buttons.CancelButton);
+            return;
         }
     } else {
        log("Use default component list");
@@ -137,7 +275,11 @@ Controller.prototype.LicenseAgreementPageCallback = function() {
 
 Controller.prototype.ReadyForInstallationPageCallback = function() {
     log("Ready to install");
-    gui.clickButton(buttons.CommitButton);
+
+    // Bug? If commit button pressed too quickly finished callback might not show the checkbox to disable running qt creator
+    // Behaviour started around 5.10. You don't actually have to press this button at all with those versions, even though gui.isButtonEnabled() returns true.
+    
+    gui.clickButton(buttons.CommitButton, 200);
 }
 
 Controller.prototype.PerformInstallationPageCallback = function() {
@@ -146,25 +288,34 @@ Controller.prototype.PerformInstallationPageCallback = function() {
 }
 
 Controller.prototype.FinishedPageCallback = function() {
+    log("FinishedPageCallback");
+
     var widget = gui.currentPageWidget();
 
-    if (widget.LaunchQtCreatorCheckBoxForm) {
-        // No this form for minimal platform
-        widget.LaunchQtCreatorCheckBoxForm.launchQtCreatorCheckBox.setChecked(false);
-    }
-    gui.clickButton(buttons.FinishButton);
+       // Bug? Qt 5.9.5 and Qt 5.9.6 installer show finished page before the installation completed
+       // Don't press "finishButton" immediately
+    
+       status.finishedPageVisible = true;
+       status.widget = widget;
+       tryFinish();   
 }
 
 EOF
 
-ARGS="-v"
-
 chmod u+x $1
 
-
-if [ -n "$VERBOSE" ]
+if [ -n "$DISABLE_PROGRESS_REPORT" ]
 then
-    QT_QPA_PLATFORM=minimal $INSTALLER $ARGS --script $SCRIPT
+       QT_QPA_PLATFORM=minimal $INSTALLER $ARGS --script $SCRIPT
 else
-    QT_QPA_PLATFORM=minimal $INSTALLER $ARGS --script $SCRIPT | grep "\(QTCI\|operation\)"
+       ARGS="-v"
+
+       if [ -n "$VERBOSE" ]
+       then
+               QT_QPA_PLATFORM=minimal $INSTALLER $ARGS --script $SCRIPT
+       else
+               QT_QPA_PLATFORM=minimal $INSTALLER $ARGS --script $SCRIPT | grep "\(QTCI\|operation\)"
+       fi
 fi
+
+
index 73398607e99d0b4d15c298d4e3ae14043a50960e..0a09064fd055f904c99e255f03d2a5c132fe2e06 100755 (executable)
@@ -1,17 +1,62 @@
-#!/bin/sh
-#QT_VERSION=5.10.0
+#!/bin/bash -e
+# Reference:
+#   https://github.com/musescore/MuseScore/blob/master/build/travis/job_macos/install.sh
+
+QT_VERSION=${1:-5.12.0}
+QT_TARGET_CATALOG=${2:-$PWD}
+QT_CI_DOWNLOADER=${QT_CI_DOWNLOADER:-"wget -c -N"}
+
+QT_MAJOR_VERSION=$(echo ${QT_VERSION} | cut -d "." -f 1)
+QT_MINOR_VERSION=$(echo ${QT_VERSION} | cut -d "." -f 2)
+if [ "$(uname)" = "Darwin" ]; then
+  if { [ "${QT_MAJOR_VERSION}" -eq 5 ] && [ "${QT_MINOR_VERSION}" -ge 9 ]; } || [ "${QT_MAJOR_VERSION}" -ge 6 ]; then
+    # this was good from 5.9.0 through at least 5.12.0
+    DOWNLOAD_URL=https://download.qt.io/archive/qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${QT_VERSION}/qt-opensource-mac-x64-${QT_VERSION}.dmg
+  else
+    # this was good from 5.2.1 through 5.8.0
+    DOWNLOAD_URL=https://download.qt.io/archive/qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${QT_VERSION}/qt-opensource-mac-x64-clang-${QT_VERSION}.dmg
+  fi
+  COMPILER=clang_64
+elif [ "$(uname)" = "Linux" ]; then
+  # this was good from 5.2.1 through at least 5.12.0
+  DOWNLOAD_URL=https://download.qt.io/archive/qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${QT_VERSION}/qt-opensource-linux-x64-${QT_VERSION}.run
+  COMPILER=gcc_64
+else
+  echo "Unsupported system." >&2
+  exit 1
+fi
+INSTALLER=$(basename $DOWNLOAD_URL)
+ENVFILE=${QT_TARGET_CATALOG}/qt-${QT_VERSION}.env
 
-QT_VERSION=$1
 echo Downloading Qt
-wget -nv -c  https://download.qt.io/archive/qt/$(echo $1 |cut -d "." -f-2)/${QT_VERSION}/qt-opensource-linux-x64-${QT_VERSION}.run
-INSTALLER=qt-opensource-linux-x64-${QT_VERSION}.run
-ENVFILE=qt-${QT_VERSION}.env
-echo Installing Qt
+${QT_CI_DOWNLOADER} ${DOWNLOAD_URL} || exit 1
 
+echo Installing Qt
+if [ "$(uname)" = "Darwin" ]; then
+  INSTALLER_NAME=${INSTALLER%.*}
+  APPFILE=/Volumes/${INSTALLER_NAME}/${INSTALLER_NAME}.app/Contents/MacOS/${INSTALLER_NAME}
+  hdiutil attach ${PWD}/${INSTALLER}
+  extract-qt-installer $APPFILE ${QT_TARGET_CATALOG}/Qt
+  # workaround apparent exit of extract-qt-installer before finished,
+  # which results in hdiutil "hdiutil: couldn't unmount "disk1" - Resource busy"
+  # and the install resources not being available.
+  #hdiutil detach /Volumes/${INSTALLER_NAME}
+  count=0
+  until hdiutil detach /Volumes/${INSTALLER_NAME} || [ $count -ge 12 ]
+  do
+    echo "Wait and attempt to detach again"
+    count=`expr $count + 1`
+    sleep 5
+  done
+elif [ "$(uname)" = "Linux" ]; then
+  extract-qt-installer ${PWD}/${INSTALLER} ${QT_TARGET_CATALOG}/Qt
+fi
 
-extract-qt-installer $PWD/$INSTALLER $PWD/Qt
+echo Create ${ENVFILE}
+if [ -d "${QT_TARGET_CATALOG}/Qt/${QT_VERSION}/${COMPILER}/bin" ]; then
+  echo "export PATH=${QT_TARGET_CATALOG}/Qt/${QT_VERSION}/${COMPILER}/bin:$PATH" > ${ENVFILE}
+elif [ -d "${QT_TARGET_CATALOG}/Qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${COMPILER}/bin" ]; then
+  # some packages use an abbreviated version x.y in the path instead of x.y.z
+  echo "export PATH=${QT_TARGET_CATALOG}/Qt/${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}/${COMPILER}/bin:$PATH" > ${ENVFILE}
+fi
 
-echo Create $ENVFILE
-cat << EOF > $ENVFILE
-export PATH=$PWD/Qt/${QT_VERSION}/gcc_64/bin:$PATH
-EOF
diff --git a/tools/qtci/qt-5.9.5-osx b/tools/qtci/qt-5.9.5-osx
deleted file mode 100755 (executable)
index 078ca16..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-# Reference:
-#   https://github.com/musescore/MuseScore/blob/master/build/travis/job_macos/install.sh
-
-echo Downloading Qt
-set -v
-set -e
-
-DOWNLOAD_URL=https://download.qt.io/archive/qt/5.9/5.9.5/qt-opensource-mac-x64-5.9.5.dmg
-INSTALLER=`basename $DOWNLOAD_URL`
-INSTALLER_NAME=${INSTALLER%.*}
-ENVFILE=qt-5.9.5-osx.env
-APPFILE=/Volumes/${INSTALLER_NAME}/${INSTALLER_NAME}.app/Contents/MacOS/${INSTALLER_NAME}
-echo $INSTALLER_NAME
-echo $APPFILE
-
-wget -nv -c $DOWNLOAD_URL
-hdiutil attach ${INSTALLER}
-ls /Volumes
-echo Installing Qt
-extract-qt-installer $APPFILE $PWD/Qt
-hdiutil detach /Volumes/${INSTALLER_NAME}
-
-echo Create $ENVFILE
-cat << EOF > $ENVFILE
-export PATH=$PWD/Qt/5.9.5/clang_64/bin:$PATH
-EOF
index 8c0cddea8ef89251ab507c37255b11a0567ef443..6e18492bb5f1539d2a87b58b92563f7d7fb8c2e3 100755 (executable)
@@ -1,24 +1,53 @@
 #!/bin/bash -ex
 #
 # This script is run on travis for the install stage of mac builds.
-# Note the script must be sourced if you want the modified PATH to
-# be used outside this script.
 #
 
+#debug failed install
+function debug() {
+  cat ${CACHEDIR}/qt-${QT_VERSION}.env
+  find ${CACHEDIR}/Qt -maxdepth 3 -ls
+  cat ${CACHEDIR}/Qt/InstallationLog.txt
+  cat ${CACHEDIR}/Qt/components.xml
+  echo "$1" >&2
+  exit 1
+}
+
+# validate install
+function validate() {
+  (
+    set +e
+    source ${CACHEDIR}/qt-${QT_VERSION}.env
+    if [ "$(qmake -query QT_INSTALL_BINS)" != "${QTDIR}/bin" ]; then
+      debug "ERROR: unexpected Qt location."
+    fi
+    if [ "$(qmake -query QT_VERSION)" != "${QT_VERSION}" ]; then
+      debug "ERROR: wrong Qt version."
+    fi
+  )
+}
+
+QT_VERSION=${1:-5.7.1}
+QT_VERSION_SHORT=${QT_VERSION//./}
+# older Qt releases use different package names and install locations.
+QT_VERSION_XY=$(echo ${QT_VERSION} | cut -d "." -f -2)
+QT_VERSION_XY_SHORT=${QT_VERSION_XY//./}
+
 # our expectation is that install-qt creates $QTDIR, $QTDIR/bin.
-QTDIR=${HOME}/Qt/5.7/gcc_64
+CACHEDIR=${HOME}/Cache
+QTDIR=${CACHEDIR}/Qt/${QT_VERSION_XY}/gcc_64
 
 if [ -d "${QTDIR}/bin" ]; then
   echo "Using cached Qt."
   echo "If you need to clear the cache see"
   echo "https://docs.travis-ci.com/user/caching/#Fetching-and-storing-caches."
 else
-  pushd ${HOME};
-  rm -fr Qt
-  # install_qt creates the install at $PWD/Qt.
-  QT_CI_PACKAGES=qt.57.gcc_64 PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} install-qt 5.7.1
-  popd;
+  rm -fr ${CACHEDIR}
+  mkdir -p ${CACHEDIR}
+  pushd ${CACHEDIR}
+  # install-qt creates the install at $PWD/Qt.
+  QT_CI_PACKAGES=qt.${QT_VERSION_XY_SHORT}.gcc_64 QT_CI_DOWNLOADER="wget -nv -c" PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} install-qt ${QT_VERSION}
+  popd
+  validate
+  rm ${CACHEDIR}/qt-opensource*.run
 fi
-# note that qt-5.7.1.env created by install-qt is not cached!
-export PATH=${QTDIR}/bin:${PATH}
-unset -v QTDIR
index 7195c96fdd8a63b5c71d9bfb358fba8dea8fbb7d..f8ddf1418c32db4e23496d81cc602991e926fd96 100755 (executable)
@@ -1,27 +1,53 @@
 #!/bin/bash -ex
 #
 # This script is run on travis for the install stage of mac builds.
-# Note the script must be sourced if you want the modified PATH to
-# be used outside this script.
 #
 
+#debug failed install
+function debug() {
+  cat ${CACHEDIR}/qt-${QT_VERSION}.env
+  find ${CACHEDIR}/Qt -maxdepth 3 -ls
+  cat ${CACHEDIR}/Qt/InstallationLog.txt
+  cat ${CACHEDIR}/Qt/components.xml
+  echo "$1" >&2
+  exit 1
+}
+
+# validate install
+function validate() {
+  (
+    set +e
+    source ${CACHEDIR}/qt-${QT_VERSION}.env
+    if [ "$(qmake -query QT_INSTALL_BINS)" != "${QTDIR}/bin" ]; then
+      debug "ERROR: unexpected Qt location."
+    fi
+    if [ "$(qmake -query QT_VERSION)" != "${QT_VERSION}" ]; then
+      debug "ERROR: wrong Qt version."
+    fi
+  )
+}
+
+QT_VERSION=${1:-5.12.0}
+QT_VERSION_SHORT=${QT_VERSION//./}
+
 # our expectation is that install-qt creates $QTDIR, $QTDIR/bin.
-QTDIR=${HOME}/Qt/5.9.7/gcc_64
+CACHEDIR=${HOME}/Cache
+QTDIR=${CACHEDIR}/Qt/${QT_VERSION}/gcc_64
 
 if [ -d "${QTDIR}/bin" ]; then
   echo "Using cached Qt."
   echo "If you need to clear the cache see"
   echo "https://docs.travis-ci.com/user/caching/#Fetching-and-storing-caches."
 else
-  pushd ${HOME};
-  rm -fr Qt
-  # install_qt creates the install at $PWD/Qt.
-  QT_CI_PACKAGES=qt.qt5.597.gcc_64,qt.qt5.597.qtwebengine PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} install-qt 5.9.7
-  popd;
+  rm -fr ${CACHEDIR}
+  mkdir -p ${CACHEDIR}
+  pushd ${CACHEDIR}
+  # install-qt creates the install at $PWD/Qt.
+  QT_CI_PACKAGES=qt.qt5.${QT_VERSION_SHORT}.gcc_64,qt.qt5.${QT_VERSION_SHORT}.qtwebengine QT_CI_DOWNLOADER="wget -nv -c" PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} install-qt ${QT_VERSION}
+  popd
+  validate
+  rm ${CACHEDIR}/qt-opensource*.run
 fi
-# note that qt-5.9.7.env created by install-qt is not cached!
-export PATH=${QTDIR}/bin:${PATH}
-unset -v QTDIR
 
 # prepare locale for test_encoding_latin1, requires locales package.
 sudo rm -rf /var/lib/apt/lists/* \
index 9518a7a50b55e506eb6ae658f793b0769f4302fc..28fa80909b571a3b227b780d450846fdc47906f4 100755 (executable)
@@ -1,24 +1,50 @@
 #!/bin/bash -ex
 #
 # This script is run on travis for the install stage of mac builds.
-# Note the script must be sourced if you want the modified PATH to
-# be used outside this script.
 #
 
-# our expectation is that qt-5.9.5-osx creates $QTDIR, $QTDIR/bin.
-QTDIR=${HOME}/Qt/5.9.5/clang_64
+#debug failed install
+function debug() {
+  cat ${CACHEDIR}/qt-${QT_VERSION}.env
+  find ${CACHEDIR}/Qt -maxdepth 3 -ls
+  cat ${CACHEDIR}/Qt/InstallationLog.txt
+  cat ${CACHEDIR}/Qt/components.xml
+  echo "$1" >&2
+  exit 1
+}
+
+# validate install
+function validate() {
+  (
+    set +e
+    source ${CACHEDIR}/qt-${QT_VERSION}.env
+    if [ "$(qmake -query QT_INSTALL_BINS)" != "${QTDIR}/bin" ]; then
+      debug "ERROR: unexpected Qt location."
+    fi
+    if [ "$(qmake -query QT_VERSION)" != "${QT_VERSION}" ]; then
+      debug "ERROR: wrong Qt version."
+    fi
+  )
+}
+
+QT_VERSION=${1:-5.12.0}
+QT_VERSION_SHORT=${QT_VERSION//./}
+
+# our expectation is that install-qt creates $QTDIR, $QTDIR/bin.
+CACHEDIR=${HOME}/Cache
+QTDIR=${CACHEDIR}/Qt/${QT_VERSION}/clang_64
 
 if [ -d "${QTDIR}/bin" ]; then
   echo "Using cached Qt."
   echo "If you need to clear the cache see"
   echo "https://docs.travis-ci.com/user/caching/#Fetching-and-storing-caches."
 else
-  pushd ${HOME};
-  rm -fr Qt
-  # qt-5.9.5-osx creates the install at $PWD/Qt.
-  QT_CI_PACKAGES=qt.595.clang_64,qt.595.qtwebengine PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} qt-5.9.5-osx;
-  popd;
+  rm -fr ${CACHEDIR}
+  mkdir -p ${CACHEDIR}
+  pushd ${CACHEDIR}
+  # install-qt creates the install at $PWD/Qt.
+  QT_CI_PACKAGES=qt.qt5.${QT_VERSION_SHORT}.clang_64,qt.qt5.${QT_VERSION_SHORT}.qtwebengine QT_CI_DOWNLOADER="wget -nv -c" PATH=${TRAVIS_BUILD_DIR}/tools/qtci:${PATH} install-qt ${QT_VERSION}
+  popd
+  validate
+  rm ${CACHEDIR}/qt-opensource*.dmg
 fi
-# note that qt-5.9.5-osx.env created by qt-5.9.5-osx is not cached!
-export PATH=${QTDIR}/bin:${PATH}
-unset -v QTDIR
index 804e1770af9749180513771222b6eac789df7d67..15d9924cc1223b9b4a32d856d92a17f7ab6cb015 100755 (executable)
@@ -5,10 +5,6 @@
 # extra ubuntu bionic packages: gcovr, openjdk-8-jre-headless, /usr/lib/jvm/java-8-openjdk-amd64/bin/java
 # as of 6/18/2018 you must use java 8, see issue #76, #83 at https://github.com/codacy/codacy-coverage-reporter/issues
 
-which qmake
-export PATH=${HOME}/Qt/5.7/gcc_64/bin:$PATH
-which qmake
-
 qmake
 make coverage